/*
https://leetcode.cn/problems/find-pivot-index/submissions/582653562/
724. 寻找数组的中心下标
*/
class Solution {
public:
    int pivotIndex(vector<int>& nums) {
        int leng=nums.size();int sum=0,total=nums[0];
        for(int i=1;i<leng;++i){
            total+=nums[i];
        }
        for(int i=0;i<leng;++i){
            if(2*sum+nums[i]==total) return i;
            sum+=nums[i];
        }
        return -1;
    }
};